package com.example.sys.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.sys.entity.DictData;
import com.example.sys.mapper.DictDataMapper;
import com.example.sys.service.DictDataService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.sys.vo.DictDataVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 字典数据表 服务实现类
 * </p>
 *
 * @author anan
 * @since 2019-06-20
 */
@Service
public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> implements DictDataService {

    @Autowired
    private DictDataMapper dictDataMapper;

    @Override
    public IPage<DictData> selectPage(DictDataVo dictDataVo) {
        IPage<DictData> iPage = new Page<>(dictDataVo.getPage(), dictDataVo.getLimit());
        QueryWrapper<DictData> wrapper = new QueryWrapper<>();
        if (!StrUtil.hasEmpty(dictDataVo.getDictType()))
            wrapper.like("dict_type", dictDataVo.getDictType());
        if (!StrUtil.hasEmpty(dictDataVo.getDictLabel()))
            wrapper.like("dict_label", dictDataVo.getDictLabel());
        if (!StrUtil.hasEmpty(dictDataVo.getStatus()))
            wrapper.like("status", dictDataVo.getStatus());
        return dictDataMapper.selectPage(iPage, wrapper);
    }
}
